/*
* Created by: yyf
* Description: 母基金管理--投资中母基金 tab详情
*/
<template>
    <div class="ca-box-border-top-none ca-p-20">
        <div v-if="!isEdit">
            <el-row>
                <el-col :span="10" class="ca-title ca-m-b-20">
                    <h3 >基本信息</h3>
                </el-col>
                <el-col :span="14" class="ca-pull-right ca-align-right" v-if="!isAdd">
                    <el-button type="text" class="ca-edit-btn el-icon-edit" @click="changeEdit(true)" :disabled="!isAuthDetailEdit">编辑</el-button>
                </el-col>
            </el-row>
            <el-form label-width="150px">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="基金规模(万元)：">{{this.fund.fundScale | format1}}</el-form-item>
                        <el-form-item label="基金类型：">{{this.fund.fundType | getNameById('fundType')}}</el-form-item>
                        <el-form-item label="董事长：" class="ca-word-break">{{this.fundMother.chairman}}</el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="投资期(年)：">{{this.fund.investmentPeriod}}</el-form-item>
                        <el-form-item label="基金类别：">{{this.fund.fundCategory | getNameById('fundCategory')}}</el-form-item>
                        <el-form-item label="总经理：" class="ca-word-break">{{this.fundMother.generalManager}}</el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="退出期(年)：">{{this.fund.exitPeriod}}</el-form-item>
                        <el-form-item label="监事会主席：" class="ca-word-break">{{this.fundMother.supervisor}}</el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="成立时间：">
                            {{this.fund.establishTime ? this.$moment(this.fund.establishTime).format('YYYY-MM-DD') : ''}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="是否备案：">
                            {{this.fundMother.backups | getNameById('whether')}}
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-form-item label="注册地点：" class="ca-word-break">{{this.region.length > 0 ? this.region[0].registrationDetailed : ''}}</el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="基金管理费(年利率)：" class="ca-word-break">{{this.fundMother.manageFee}}</el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="基金管理人：" class="ca-word-break">{{this.fundMother.manager}}</el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="基金托管人：" class="ca-word-break">{{this.fundMother.custodian}}</el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="管理公司：" class="ca-word-break">{{this.fundMother.managementCompany}}</el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="基金简介：" class="ca-word-break">{{this.fundMother.brief}}</el-form-item>
                </el-row>
            </el-form>
        </div>
        <csDetailEdit v-if="isEdit"
                      :isAdd="false"
                      @changeEdit="changeEdit"
                      @save="save"
                      @changeRegion="changeRegion"
                      :fund="fund"
                      :fundMother="fundMother"
                      :region="region">
        </csDetailEdit>
    </div>
</template>

<script type="text/ecmascript-6">
        import {api} from '../api';
        import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
        import { isNoAuth } from '__service/utils';
    export default {
        data() {
            return {
                initView: {
                    fundCategory: [{id: '', name: '请选择'}, ...this.$store.state.user.dictionaryMap.fundCategory],// 基金类别
                    fundType: [{id: '', name: '请选择'}, ...this.$store.state.user.dictionaryMap.fundType],// 基金类型
                    reference: [{id: '', name: '请选择'}, ...this.$store.state.user.dictionaryMap.whether], // 是否备案
                },
                itemId: this.$route.params.itemId,
                isEdit: false,
                isAuthDetailEdit: isNoAuth('投资中母基金-母基金详情-编辑'),
            };
        },
        props: ['isAdd', 'fund', 'fundMother', 'region'],
        mounted() {
        },
        methods: {
            // 保存
            async save() {
                let {resCode} = await apiHttp(api.EDIT_FUND_MOTHER, {
                    fund: this.fund,
                    fundMother: this.fundMother,
                    region: this.region
                });
                if (resCode === STATUS_HTTP_SUCCESS) {
                    this.$message({
                        type: 'success',
                        message: '修改成功！',
                        center: true
                    })
                    // 添加小红点
                    this.$emit('addRedDot');
                }
                this.changeEdit(false);
            },
            // 进入编辑页
            changeEdit(val) {
                if (val === false) {
                    this.$emit('getFundsDetail');
                }
                this.isEdit = val;
            },
            // 改变注册地点
            changeRegion(val) {
                this.$emit('changeRegion', val);
            }
        },
        components: {
            'csDetailEdit': require('./edit'), // 详情编辑
        }
    }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
    .ca-w-100 {
        width: 100%;
    }
    .ca-word-break {
        width: 100%;
        word-break: break-all;
    }
</style>
